home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Standards 1994 January / InfoMagic Standards - January 1994.iso / misc / filetran / modem7.doc < prev    next >
Text File  |  1991-10-27  |  13KB  |  425 lines

  1.           THE TOPS-20 IMPLEMENTATION OF THE MODEM7 PROTOCOL
  2.  
  3. Copyright (C) 1985 Frank J. Wancho
  4.  
  5. This draft document describes the MODEM7 Protocol as implemented in
  6. the TOPS-20 MODEM program.  The TOPS-20 MODEM program was originally
  7. written by Bill Westfield (BILLW@SCORE), and is currently maintained
  8. by Frank Wancho (WANCHO@SIMTEL20).  The current source file is
  9. available in MICRO:<CPM.TOPS-20>MODEM.MAC along with other TOPS-20
  10. utilities via ANONYMOUS FTP to SIMTEL20.
  11.  
  12. The sections are:
  13.  
  14.     A.  SEND A FILE
  15.  
  16.     B.  SEND A FILENAME
  17.  
  18.     C.  RECEIVE A FILE
  19.  
  20.     D.  RECEIVE A FILENAME
  21.  
  22.     E.  ABORT PROCESSING
  23.  
  24. For file transfer operations, the TOPS-20 MODEM program accepts the
  25. following command format:
  26.  
  27.     S|R [B|A] [N] filespec
  28.  
  29. S or R for Send or Receive.
  30.  
  31. B or A for Binary or ASCII storage (Receive only).
  32.  
  33. N for Network Binary Mode, which must be specified if the user is
  34. connected through a TAC port.
  35.  
  36. filespec may be unambiguous (a single filename) or ambiguous
  37. (containing wildcard characters).  If the filespec is ambiguous, Batch
  38. Mode is automatically assumed and the received files are stored in
  39. Binary format for subsequent post-processing, whether or not the A or
  40. B sub-options were specified.
  41.  
  42.  
  43. A.  SEND A FILE:
  44.  
  45.     1.  Get sub-options and set flag if N option requested to
  46.         handle binary negotiations for an end-user on a TAC.
  47.         Ignore all other sub-options.
  48.  
  49.     2.  Disable ^C interrupts if not a controlling terminal.  A
  50.         controlling terminal is the one a user is one when using a
  51.         dialout modem.
  52.  
  53.     3.  Parse the filename requested.
  54.  
  55.     4.  Get next filename if it is a wildcard filename.
  56.  
  57.     5.  Determine type of file and open file accordingly.  Files
  58.         may be any one of three types: ASCII, TOPS-20 Binary, or
  59.         ITS Binary.  ITS Binary is the same as TOPS-20 Binary, but
  60.         has a unique four-byte header which must be skipped.
  61.  
  62.     6.  Turn on network binary mode if the N sub-option flag is
  63.         set.  By default, a TAC connection is 7 bits per
  64.         character.  Network binary mode turns on 8-bit
  65.         transparency at the TAC.
  66.  
  67.     7.  If the parsed filename was wildcarded, assume implicit
  68.         batch mode and send filename.  The SEND FILENAME protocol
  69.         is described in a separate section below.
  70.  
  71.     8.  Set record number to zero.
  72.  
  73.     9.  Clear the CRC flag.
  74.  
  75.     10. Set timeout counter to 120 (two minutes).
  76.  
  77.     11. Wait one second for a character:
  78.  
  79.         a.  If no character is received within one second, decrement
  80.         and check the timeout counter.  If timeout counter has
  81.         not reached zero, wait another second for a character,
  82.         otherwise abort process.
  83.  
  84.         b.  If a character has been received within the one-second
  85.         timeout, check its value:
  86.  
  87.         1).  If it is a "C", set the CRC flag and proceed to
  88.              Step 12.
  89.  
  90.         2).  If it is a CAN (^X), go to ABORT PROCESSING.
  91.  
  92.         3).  If it is a NAK (^U), proceed to Step 12.
  93.  
  94.         4).  If it is none of the above, decrement and check
  95.              the timeout counter.  If timeout counter has
  96.              not reached zero, wait another second for a
  97.              character, otherwise go to ABORT PROCESSING.
  98.  
  99.     12. Set the error counter to 10.
  100.  
  101.     13. If EOF has been reached:
  102.  
  103.         a.  Send EOT (^D) and wait for ACK (^F).  If ACK is not
  104.         received within 15 seconds, send EOT again, and wait
  105.         for ACK.
  106.  
  107.         b.  If wildcard flag is on, go to Step 4.
  108.  
  109.         c.  Close file and exit program or return to command mode.
  110.  
  111.     14. Get the next 128-byte buffer to send.  If the buffer is
  112.         not full, pad the buffer with SUBs (^Zs) if the file is
  113.         ASCII, or with NULLs (^@s) if the file is binary.
  114.  
  115.     15. If buffer is empty, go to Step 13.
  116.  
  117.     16. Increment record count and set timeout counter to 10.
  118.  
  119.     17. Zero Checksum and CRC registers.
  120.  
  121.     18. Send header consisting of an SOH (^A), record count modulo
  122.         256 and its ones complement.
  123.  
  124.     19. Send the buffer as a binary string.
  125.  
  126.     20. Compute and send either the checksum byte or the two-byte
  127.         CRC value (high order byte first), depending on the
  128.         setting of the CRC flag.
  129.  
  130.     21. Set the timeout counter to 192 (192 seconds).
  131.  
  132.     22. Wait for an character with one-second timeout.
  133.  
  134.         a.  If an ACK (^F), go to Step 12 to send next buffer.
  135.  
  136.         b.  If a NAK (^U), decrement and check the error counter.
  137.         If the error counter is exhausted, go do ABORT
  138.         PROCESSING.  Otherwise go to Step 17 to resend the
  139.         same buffer.
  140.  
  141.         c.  If neither character received was an ACK or a NAK, or
  142.         the one-second receive character routine timed out,
  143.         decrement and check the timeout counter.  If the
  144.         timeout counter is exhausted, go do ABORT PROCESSING.
  145.         Othewise go wait for another character.
  146.  
  147.  
  148. B.  SEND A FILENAME:
  149.  
  150.     1.  Get filename into a buffer with a maximum of the first
  151.         eight characters blank filled stuffed into the first eight
  152.         positions of the buffer and with a maximum of the first
  153.         three characters of the extent blank filled stuffed into
  154.         the next three positions of the buffer.
  155.  
  156.     2.  Wait up to two minutes for the initial NAK (^U).  If two
  157.         minutes elapses, send an ACK (^F), then send an EOT (^D)
  158.         to indicate no more files, and either exit the program or
  159.         return to command mode.
  160.  
  161.     3.  Send an ACK (^F).
  162.  
  163.     4.  Set the character counter to 11.
  164.  
  165.     5.  Zero the checksum register.
  166.  
  167.     6.  Set the buffer pointer to the first character in the
  168.         buffer.
  169.  
  170.     7.  Skip any TOPS-20 quoting characters (^V) and get the next
  171.         character to be sent.
  172.  
  173.     8.  Add it to the checksum register.
  174.  
  175.     9.  Send the character.
  176.  
  177.     10. Wait up to 15 seconds for an ACK.  If 15 seconds elapses
  178.         without receiving an ACK, send a "u" and go to Step 2.
  179.  
  180.     11. If an ACK is received, decrement and check the character
  181.         counter.  If the counter is not zero, got to Step 7.
  182.  
  183.     12. Send a SUB (^Z) indicating the end of the filename.
  184.  
  185.     13. Wait up to 16 seconds to receive the checksum byte
  186.         computed by the receiving end.  If 16 seconds elapses
  187.         without receiving anything, send a "u" and go to Step 2.
  188.  
  189.     14. Add a SUB to the checksum register modulo 256 and compare
  190.         it with the received checksum.  If there is no match, send
  191.         a "u" and go to Step 2.
  192.  
  193.     15. Send an ACK and proceed to sending the file itself.
  194.  
  195.  
  196. C.  RECEIVE A FILE:
  197.  
  198.     1.  Get any sub-options, setting a flag if the N sub-option is
  199.         requested, and the Binary flag if the B sub-option is
  200.         requested.  Otherwise, assume the file to be received is
  201.         to be stored as an ASCII file.
  202.  
  203.     2.  Parse the filename from the command line.
  204.  
  205.     3.  If a wildcard filespec is given, set a flag.  Otherwise
  206.         open the specified filename according to the mode
  207.         requested in the sub-options.
  208.  
  209.     4.  Determine the block wait time from the speed of the line.
  210.         This value is computed to be three times the length of
  211.         time it should take for the sending end to transmit a
  212.         128-byte block.  The default value is 13 seconds if the
  213.         speed of the line cannot be determined, as is currently
  214.         the case with a network connection.
  215.  
  216.     5.  Turn on network binary mode if requested.
  217.  
  218.     6.  Disable ^C interrupts if not a controlling terminal.
  219.  
  220.     7.  If wildcard mode is on, get the filename and open the file
  221.         in Binary Mode regardless of any requested suboption.  The
  222.         RECEIVE A FILENAME Protocol is described below in a
  223.         separate section.
  224.  
  225.     8.  Zero the record number counter.
  226.  
  227.     9.  Zero the last record received counter.
  228.  
  229.     10. Set the timeout counter to 7.
  230.  
  231.     11. Turn the CRC flag ON.
  232.  
  233.     12. Decrement and check the timeout counter.  Go to Step 14 if
  234.         exhausted.
  235.  
  236.     13. Send a "C" and wait ten seconds for a reply:
  237.  
  238.         a.  If ten seconds lapse without receiving a character, go
  239.         to Step 12.
  240.  
  241.         b.  If the received character is an EOT (^D), go to Step 34.
  242.  
  243.         c.  If the received character is a CAN (^X), go to ABORT
  244.         PROCESSING.
  245.  
  246.         d.  If the received character is an SOH (^A), reset the
  247.         timeout counter to 11 and go to Step 20.
  248.  
  249.         e.  If none of the above, go to Step 12.
  250.  
  251.     14. Turn the CRC flag off.
  252.  
  253.     15. Set the timeout (error) counter to 11.
  254.  
  255.     16. Decrement and check the timeout counter.  Go to ABORT
  256.         PROCESSING if exhausted.
  257.  
  258.     17. Send a NAK.
  259.  
  260.     18. Zero the Checksum register.
  261.  
  262.     19. Wait up to 16 seconds for a response:
  263.  
  264.         a.  If the 16 seconds elapses without receiving a
  265.         character, go to Step 16.
  266.  
  267.         b.  If the received character is an EOT (^D), go to Step 34.
  268.  
  269.         c.  If the received character is a CAN (^X), go do ABORT
  270.         PROCESSING.
  271.  
  272.         d.  If the received character is not an SOH (^A), go to
  273.         Step 19.
  274.  
  275.     20. Add the received character to the checksum register.
  276.  
  277.     21. Wait up to 16 seconds for the next byte.
  278.         If 16 seconds elapse, wait for the line to go quiet for
  279.         one second, send a NAK (i.e., flush the line), and go to
  280.         Step 16.
  281.  
  282.     22. Save the received byte as the record number.
  283.  
  284.     23. Add the record number to the checksum register.
  285.  
  286.     24. Wait up to 16 seconds for the record number complement.
  287.         If 16 seconds elapse, flush the line and go to Step 16.
  288.  
  289.     25. Add the received record number complement to the checksum
  290.         register.
  291.  
  292.     26. If the checksum register is not zero, flush the line and
  293.         go to Step 16.
  294.  
  295.     27. Accumulate the next 128 bytes in the block wait time
  296.         computed in Step 4.  Most implementations of this protocol
  297.         set a counter to 128 and wait with a one-second timeout
  298.         for each of the 128 characters, falling through to the
  299.         next Step if any timout occurs.
  300.  
  301.     28. If the block wait time expires without receiving all 128
  302.         bytes, flush the line and go to Step 16.
  303.  
  304.     29. If the CRC flag is OFF:
  305.  
  306.         a.  Wait up to 16 seconds for the sender's checksum and if
  307.         a timeout occurs, flush the line and go to Step 16.
  308.  
  309.         b.  Save the received checksum and compute the checksum
  310.         for the received block.
  311.  
  312.         c.  If the checksums do not match, flush the line and go
  313.         to Step 16.
  314.  
  315.     30. If the CRC flag is ON:
  316.  
  317.         a.  Wait up to 16 seconds for each of the two bytes of the
  318.         sender's CRC.  If a timeout occurs, flush the line and
  319.         go to Step 16.
  320.  
  321.         b.  Save each received byte of the CRC and compute the CRC
  322.         value for the received block.
  323.  
  324.         c.  If the CRCs do not match, flush the line and go to
  325.         Step 16.
  326.  
  327.     31. Check the received record number:
  328.  
  329.         a.  If the received record number matches the expected
  330.         record number, i.e., the previously received record
  331.         number plus one, save the current record number as the
  332.         previously received record number.
  333.  
  334.         b.  If the received record number is the same as the
  335.         previously received record number, go to Step 33.
  336.  
  337.         c.  If neither, go to ABORT PROCESSING.
  338.  
  339.     32. Save the 128-byte buffer to disk.
  340.  
  341.     33. Send an ACK, reset the timeout counter to 10, and go to
  342.         Step 18.
  343.  
  344.     34. Send an ACK and close the file.
  345.  
  346.     35. If the wildcard flag is set, go to Step 7.  Otherwise, go
  347.         back to command mode or exit the program.
  348.  
  349.  
  350. D.  RECEIVE A FILENAME:
  351.  
  352.     1.  Zero the checksum register.
  353.  
  354.     2.  Set the timeout counter to 180 for a three-minute wait.
  355.  
  356.     3.  Send a NAK.
  357.  
  358.     4.  Wait one second for a response:
  359.  
  360.         a.  If no response in one second, decrement and check the
  361.         timeout counter.  If the counter has expired, go to
  362.         Step 14.  Otherwise, go to Step 3.
  363.  
  364.         b.  If a character is received and it is not an ACK (^F),
  365.         decrement and check the timeout counter.  If the
  366.         counter has expired, go to Step 14.  Otherwise, go to
  367.         Step 3.
  368.  
  369.     5.  Set up the filename buffer for 12 characters and character
  370.         counter to receive 11 characters of the filename.
  371.  
  372.     6.  Wait up to 16 seconds for a character of the file name:
  373.  
  374.         a.  If 16 seconds elapse without receiving a character, go
  375.         to Step 1.
  376.  
  377.         b.  If the received character is an EOT (^D), go to Step
  378.         14.  (An EOT means no more files to receive.)
  379.  
  380.     7.  Add the received character to the checksum register.
  381.  
  382.     8.  Check the received character:
  383.  
  384.         a.  If it is neither a SPACE nor a NULL, and is not the
  385.         "ninth" received character, stuff a ^V (the TOPS-20
  386.         quote character) into the filename buffer and then the
  387.         received character.
  388.  
  389.         b.  If it is the ninth, stuff a period into the filename
  390.         buffer, then a ^V and the received character.
  391.  
  392.         c.  If it is either a SPACE or a NULL and the ninth
  393.         character has not yet been received, stuff a period
  394.         into the filename buffer and set character counter to
  395.         indicate that the "ninth" character has been received.
  396.  
  397.     9.  Send an ACK, decrement the character counter and go to
  398.         Step 6 if the counter is not exhausted.
  399.  
  400.     10. Wait up to 16 seconds for the next character.
  401.         If the received character is not a SUB (^Z) or 16 seconds
  402.         elapsed without receiving any character, go to Step 1.
  403.  
  404.     11. Add the ^Z to the checksum register and send the contents
  405.         of the checksum register.
  406.  
  407.     12. Wait up to 15 seconds for an ACK.  If the timeout expires,
  408.         go to Step 1.
  409.  
  410.     13. Open the requested filename, wait two seconds, and return
  411.         to the caller.
  412.  
  413.     14. Send an ACK and wait for the line to be quiet for one
  414.         second.  Restore the stack and return to command mode or
  415.         exit the program.
  416.  
  417.  
  418. E.  ABORT PROCESSING
  419.  
  420.     1.  Close any open file.
  421.  
  422.     2.  Flush the line.
  423.  
  424.     3.  Return to command mode or exit the program.
  425.